$(function() {
	var telcode = $('#J_GetCode');
	telcode.sendCode({
		disClass: 'btn-disabled',
		secs: 60,
		run: false,
		runStr: '{%s}秒后重新获取',
		resetStr: '获取验证码'
	});
	$("#img").click(function() {
		$(this).attr("src", "imageCode?r=" + parseInt(Math.random() * 1000));
	})
	telcode.on('click', function() {
		
		var tel = $("#tel").val()
		if(tel == "") {
			YDUI.dialog.alert("请输入您手机号", function() {})
			return
		}
		
		if(tel.length != 11) {
			YDUI.dialog.alert("请输入11位有效手机号")
			return
		}
		if(checkPhone(tel) == false) {
			YDUI.dialog.alert("请输入正确的手机号")
			return
		}
		var imgcode = $("#imgyzm").val()
		if(imgcode == "") {
			YDUI.dialog.alert("请输入图形验证码")
			return
		}
		
		YDUI.dialog.loading.open('发送中');
		$.post("sendTXSMSCode", {
			"mobile": tel,
			"imageCode": imgcode
		}, function(data) {
			if(data.code==0) {
				YDUI.dialog.loading.close();
				telcode.sendCode('start');
				YDUI.dialog.toast(data.msg, 'success', 1500);
			} else {
				YDUI.dialog.alert(data.msg);
				YDUI.dialog.loading.close();
				tximg()
			}
		})

	});
	//提交信息
	$("#tj").click(function(){
		var name=$("#name").val()
		if(name == "") {
			YDUI.dialog.alert("请输入您的姓名")
			return
		}
		var sfzh=$("#sfzh").val()
		if(sfzh==""){
			YDUI.dialog.alert("请输入您的身份证号或者对公账号")
			return
		}
		/*if(checkCode(sfzh)==false){
			YDUI.dialog.alert("请输入正确的身份证号")
			return
		}*/
		var tel = $("#tel").val()
		if(tel == "") {
			YDUI.dialog.alert("请输入您手机号", function() {})
			return
		}
		if(tel.length != 11) {
			YDUI.dialog.alert("请输入11位有效手机号")
			return
		}
		if(checkPhone(tel) == false) {
			YDUI.dialog.alert("请输入正确的手机号")
			return
		}
		var imgcode = $("#imgyzm").val()
		if(imgcode == "") {
			YDUI.dialog.alert("请输入图形验证码")
			return
		}
		var yzm=$("#yzm").val()
		if(yzm==""){
			YDUI.dialog.alert("请输入短信验证码")
			return
		}
		var senddata={"userName":name,"idCard":sfzh,"phone":tel,"code":yzm}
		$.post("savekhxx",senddata,function(data){
			if(data.code==0){
				YDUI.dialog.alert(data.msg,function(data){
					window.location.replace("http://yykh.czzrcb.com/zzhddj/getNqjCode")
				})
			}else{
				YDUI.dialog.alert(data.msg)
			}
		})
	})
	function tximg() {
		$("#img").attr("src", "imageCode?r=" + parseInt(Math.random() * 1000));
	}
})